home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / catD / pciio_config.z / pciio_config
Encoding:
Text File  |  2002-10-03  |  12.7 KB  |  331 lines

  1.  
  2.  
  3.  
  4. ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))                                              ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      pciio_config: pciio_config_get, pciio_config_set - access PCI
  10.      Configuration register
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////PPPPCCCCIIII////ppppcccciiiiiiiioooo....hhhh>>>>
  14.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////PPPPCCCCIIII////PPPPCCCCIIII____ddddeeeeffffssss....hhhh>>>>
  15.  
  16.      uuuuiiiinnnntttt66664444____tttt
  17.      ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg____ggggeeeetttt((((
  18.           vvvveeeerrrrtttteeeexxxx____hhhhddddllll____tttt _v_h_d_l,,,,
  19.           uuuunnnnssssiiiiggggnnnneeeedddd _r_e_g,,,,
  20.           uuuunnnnssssiiiiggggnnnneeeedddd _s_i_z_e))))
  21.  
  22.      vvvvooooiiiidddd
  23.      ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg____sssseeeetttt((((
  24.           vvvveeeerrrrtttteeeexxxx____hhhhddddllll____tttt _v_h_d_l,,,,
  25.           uuuunnnnssssiiiiggggnnnneeeedddd _r_e_g,,,,
  26.           uuuunnnnssssiiiiggggnnnneeeedddd _s_i_z_e,,,,
  27.           uuuuiiiinnnntttt66664444____tttt _v_a_l_u_e ))))
  28.  
  29.    AAAArrrrgggguuuummmmeeeennnnttttssss
  30.      _v_h_d_l    The connection point of the PCI device, as passed to the driver's
  31.              _a_t_t_a_c_h() entry point.
  32.  
  33.      _r_e_g     Byte offset of the register of interest in the PCI address space.
  34.  
  35.      _s_i_z_e    Width of the target register in bytes.
  36.  
  37.      _v_a_l_u_e   Value to be written to the specified register.
  38.  
  39. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  40.      Various SGI platforms introduce complexities and restrictions in how
  41.      Configuration Space cycles are generated on the PCI bus.  For instance,
  42.      some platforms may require all PCI Configuration accesses to be done
  43.      using 32-bit wide accesses.  Other platforms may require more than a
  44.      simple load or store to trigger the actual cycle, so that configuration
  45.      access cannot be performed using simple PIO loads and stores.  The
  46.      functions described here allow the hardware differences to be
  47.      encapsulated behind a single interface, so PCI drivers do not have to
  48.      know the details of each platform.
  49.  
  50.      The _r_e_g value specifies the offset of the target value in configuration
  51.      space.  The _s_i_z_e value specifies the width of the target value.
  52.      Registers defined by the standard are 1, 2, 3, 4, or 8 bytes, but the
  53.      functions permit any size from 1-8 bytes.  Eight-byte registers are
  54.      returned in proper byte and word order.
  55.  
  56.      Some implementations must access configuration space in 32-bit units on
  57.      32-bit boundaries, while other implementations may do this for
  58.      performance reasons.  When _r_e_g and _s_i_z_e specify a standard PCI
  59.      configuration register, _p_c_i_i_o__c_o_n_f_i_g__g_e_t() shifts and masks appropriately
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))                                              ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))
  71.  
  72.  
  73.  
  74.      to return just the value of the register.  Similarly, _p_c_i_i_o__c_o_n_f_i_g__s_e_t()
  75.      executes a read-merge-write operation to place the data in the correct
  76.      portion of the word.
  77.  
  78.    SSSSttttaaaannnnddddaaaarrrrdddd PPPPCCCCIIII CCCCoooonnnnffffiiiigggguuuurrrraaaattttiiiioooonnnn RRRReeeeggggiiiisssstttteeeerrrrssss
  79.      To access vendor-specific registers, specify the base address in PCI
  80.      configuration space, bearing in mind that PCI places the least
  81.      significant data in the lowest offset.
  82.  
  83.      The following constants are used as the _r_e_g value to specify a standard
  84.      register in the Type 00 PCI configuration space:
  85.  
  86.  
  87.           PCI_CFG_VENDOR_ID
  88.           PCI_CFG_DEVICE_ID
  89.           PCI_CFG_COMMAND
  90.           PCI_CFG_STATUS
  91.  
  92.           PCI_CFG_REV_ID
  93.           PCI_CFG_BASE_CLASS
  94.           PCI_CFG_SUB_CLASS
  95.           PCI_CFG_PROG_IF
  96.  
  97.           PCI_CFG_CACHE_LINE
  98.           PCI_CFG_LATENCY_TIMER
  99.           PCI_CFG_HEADER_TYPE
  100.           PCI_CFG_BIST
  101.  
  102.           PCI_CFG_BASE_ADDR(0)
  103.           PCI_CFG_BASE_ADDR(1)
  104.           PCI_CFG_BASE_ADDR(2)
  105.           PCI_CFG_BASE_ADDR(3)
  106.           PCI_CFG_BASE_ADDR(4)
  107.           PCI_CFG_BASE_ADDR(5)
  108.  
  109.           PCI_CFG_CARDBUS_CIS
  110.           PCI_CFG_SUBSYS_VEND_ID
  111.           PCI_CFG_SUBSYS_ID
  112.           PCI_CFG_PCI_EXPANSION_ROM
  113.  
  114.           PCI_INTR_LINE
  115.           PCI_INTR_PIN
  116.           PCI_MIN_GNT
  117.           PCI_MAX_LAT
  118.           Use PCI_CFG_VEND_SPECIFIC to specify the first vendor-specific
  119.           register word.
  120.  
  121. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  122.      Most things that drivers might think they need to set up in their
  123.      configuration space have already been taken care of by the
  124.      infrastructure, including checking the VENDOR and DEVICE identifiers,
  125.      allocating PCI space appropriately and assigning values to the BASE
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))                                              ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))
  137.  
  138.  
  139.  
  140.      registers, enabling DMA, Memory and I/O decode, and setting up the
  141.      system-specific values for other registers as appropriate; so we expect
  142.      that many PCI drivers will never actually need to worry about their
  143.      configuration space at all.
  144.  
  145.      This example reflects a driver that is supporting multiple revisions of a
  146.      card, where the revision code needs to be stored for later use.
  147.  
  148.           pcifoo_attach(vertex_hdl_t conn)
  149.           {
  150.                ...
  151.                /* retrieve current device revision */
  152.                foo_soft->fs_revision =
  153.                     pciio_config_get(conn, PCI_CFG_REV_ID, 1);
  154.                ...
  155.                /* write 0x5555AAAA test pattern to first
  156.                ** vendor specific register */
  157.                pciio_config_set(conn, PCI_CFG_VEND_SPECIFIC, 4,
  158.                     0x5555AAAA);
  159.           }
  160.  
  161.  
  162. NNNNOOOOTTTTEEEESSSS
  163.      Access to sizes or alignments not directly supported by the processor or
  164.      any bus or bus adapter between the processor and the PCI device may
  165.      result in multiple CFG cycles being used to construct the access.
  166.  
  167.      A number of SGI-built PCI peripherals require all CFG space accesses to
  168.      use all byte lanes.  In support of this, all current _p_c_i_i_o__c_o_n_f_i_g__g_e_t()
  169.      provider implementations always read the entire 32-bit wide word, then
  170.      extract the register of interest using shift and mask operations.  This
  171.      is also faster than switching between various load sequences based on the
  172.      size and alignment of the register.
  173.  
  174.      On systems that are unable to initiate store cycles with only some byte
  175.      lanes enabled, support code may synthesize the transaction effect by
  176.      reading the word containing the register, modifying the proper bits in
  177.      the word, then rewriting the entire bus word.  This synthesis code knows
  178.      about the special handling of the STATUS register.  However, if other
  179.      registers in your card's configuration space are sensitive to being
  180.      rewritten, you should access other registers in the same word as the
  181.      sensitive ones using full four-byte-wide accesses, manipulating the word
  182.      data appropriately.
  183.  
  184.    PPPPrrrreeeevvvviiiioooouuuussss RRRReeeelllleeeeaaaasssseeeessss
  185.      In IRIX 6.3, the functions with the names _p_c_i_i_o__c_o_n_f_i_g__g_e_t and
  186.      _p_c_i_i_o__c_o_n_f_i_g__s_e_t took different arguments than these functions do, and
  187.      had more restrictions.  When porting from IRIX 6.3, some recoding of
  188.      configuration access is needed.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))                                              ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))
  203.  
  204.  
  205.  
  206.      All systems supported by IRIX 6.4 permitted direct PIO access to
  207.      configuration space.  Accordingly, IRIX 6.4 included no configuration
  208.      access functions.  When porting from IRIX 6.4, configuration access must
  209.      be recoded to use these functions in order to avoid being platform-
  210.      dependent.
  211.  
  212.      It is possible to code configuration access call macros so that they
  213.      compile properly in all releases from 6.3 onward.  The macro code would
  214.      be similar to the following:
  215.  
  216.           /* PCI Config Space Access Macros
  217.           ** for source compatibility in drivers
  218.           ** that need to use the same source
  219.           ** for IRIX 6.3, IRIX 6.4, and IRIX 6.5
  220.           **
  221.           ** PCI_CFG_BASE(conn)
  222.           ** PCI_CFG_GET(conn,base,offset,type)
  223.           ** PCI_CFG_SET(conn,base,offset,type,value)
  224.           **
  225.           ** Use PCI_CFG_BASE once during attach to get the
  226.           ** base value to be used for the specific device.
  227.           ** Later, use PCI_CFG_GET to read and PCI_CFG_SET
  228.           ** to write config registers.
  229.           **
  230.           ** NOTE: Irix 6.3 determines the size of the register
  231.           ** directly on its own, based on the layout of a Type 00
  232.           ** PCI Configuration Space Header. If you specify a
  233.           ** nonstandard size, you will get different results
  234.           ** depending on the system revision number.
  235.           */
  236.           #if IRIX6_3
  237.           #define   PCI_CFG_BASE(c)          pciio_piotrans_addr(c,0,PCIIO_SPACE_CFG,0,256,0)
  238.           #define   PCI_CFG_GET(c,b,o,t)     pciio_config_get(b,o)
  239.           #define   PCI_CFG_SET(c,b,o,t,v)   pciio_config_set(b,o,v)
  240.           #elif IRIX6_4
  241.           #define   PCI_CFG_BASE(c)          pciio_piotrans_addr(c,0,PCIIO_SPACE_CFG,0,256,0)
  242.           #define   PCI_CFG_GET(c,b,o,t)     ((*(t *)((char *)(b)+(o))))
  243.           #define   PCI_CFG_SET(c,b,o,t,v)   ((*(t *)((char *)(b)+(o))) = v)
  244.           #else     /* starting in IRIX 6.5 */
  245.           #define   PCI_CFG_BASE(c)          NULL
  246.           #define   PCI_CFG_GET(c,b,o,t)     pciio_config_get(c,o,sizeof(t))
  247.           #define   PCI_CFG_SET(c,b,o,t,v)   pciio_config_set(c,o,sizeof(t),v)
  248.           #endif
  249.  
  250.      The macros would be used approximately as follows (repeating the example
  251.      from the preceding section):
  252.  
  253.           pcifoo_attach(vertex_hdl_t conn)
  254.           {
  255.                void * config_base = PCI_CFG_BASE(conn);
  256.                ...
  257.                /* retrieve current device revision */
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))                                              ppppcccciiiiiiiioooo____ccccoooonnnnffffiiiigggg((((DDDD3333))))
  269.  
  270.  
  271.  
  272.               foo_soft->fs_revision =
  273.                     PCI_CFG_GET(conn, config_base, PCI_CFG_REV_ID, uchar);
  274.                ...
  275.                /* write 0x5555AAAA test pattern to first
  276.                ** vendor specific register */
  277.                PCI_CFG_SET(conn, config_base, PCI_CFG_VEND_SPECIFIC, uint32_t,
  278.                     0x5555AAAA);
  279.           }
  280.  
  281.  
  282. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  283.      pciio(D3), pciio_config(D3), pciio_dma(D3), pciio_error(D3),
  284.      pciio_get(D3), pciio_intr(D3).  pciio_pio(D3).
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.